package com.autumn.sms.service.controller;

import javax.validation.Valid;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.autumn.application.dto.PageQueryResult;
import com.autumn.application.dto.input.DefaultPrimaryKeyInput;
import com.autumn.sms.service.consts.UrlConsts;
import com.autumn.sms.service.services.IPlatformTemplateService;
import com.autumn.sms.service.services.dto.input.PageQueryByPlatformIdAndTemplateIdInput;
import com.autumn.sms.service.services.dto.input.PageQueryByPlatformIdInput;
import com.autumn.sms.service.services.dto.input.PlatformTemplateInput;
import com.autumn.sms.service.services.dto.input.PlatformTemplateUpdateInput;
import com.autumn.sms.service.services.dto.output.PlatformTemplateOutput;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 平台模板模板控制器
 * 
 * @author JuWa ▪ Zhang
 * @date 2018年1月17日
 * @since jdk 1.8
 */
@Api(tags = "短信后台-平台模板")
@RestController
@RequestMapping(UrlConsts.PLATFORM_TEMPLATE)
public class PlatformTemplateController {

	@Autowired
	private IPlatformTemplateService service;

	@GetMapping("/get")
	@ApiOperation("获取平台模板信息")
	public PlatformTemplateOutput get(@Valid DefaultPrimaryKeyInput input) {
		return service.get(input);
	}

	@PostMapping("/add")
	@ApiOperation("新增平台模板信息")
	public PlatformTemplateOutput add(@Valid @RequestBody PlatformTemplateInput input) {
		return service.add(input);
	}

	@PostMapping("/modify")
	@ApiOperation("更新平台模板信息")
	public PlatformTemplateOutput modify(@Valid @RequestBody PlatformTemplateUpdateInput input) {
		return service.modify(input);
	}

	@PostMapping("/delete")
	@ApiOperation("/删除平台模板信息")
	public void delete(@Valid @RequestBody DefaultPrimaryKeyInput input) {
		service.delete(input);
	}

	@PostMapping("/release")
	@ApiOperation("发布平台模板信息")
	public void release(@Valid @RequestBody DefaultPrimaryKeyInput input) {
		service.release(input);
	}

	@PostMapping("/disable")
	@ApiOperation("停用平台模板")
	public void disable(@Valid @RequestBody DefaultPrimaryKeyInput input) {
		service.disable(input);
	}

	@PostMapping("/pagequery")
	@ApiOperation("根据平台ID分页查询")
	public PageQueryResult<PlatformTemplateOutput> pageQueryByPlatformId(
			@Valid @RequestBody PageQueryByPlatformIdInput input) {
		return service.pageQueryByPlatformId(input);
	}

	@PostMapping("/pagequeryByTemplateId")
	@ApiOperation("根据平台ID和标准模板ID分页查询")
	public PageQueryResult<PlatformTemplateOutput> pageQueryByPlatformIdAndTemplateId(
			@Valid @RequestBody PageQueryByPlatformIdAndTemplateIdInput input) {
		return service.pageQueryByPlatformIdAndTemplateId(input);
	}

}
